package cn.stylefeng.guns.modular.api.tips;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(value="返回对象",description="返回对象信息")
public class ApiResponseData<T> {

    public static final String DEFAULT_SUCCESS_MESSAGE = "操作成功";

    public static final String DEFAULT_ERROR_MESSAGE = "网络异常";

    public static final Integer DEFAULT_SUCCESS_CODE = 200;

    public static final Integer DEFAULT_ERROR_CODE = 500;

    /**
     * 请求是否成功
     */
    private Boolean success;

    /**
     * 响应状态码
     */
    private Integer code;

    /**
     * 响应信息
     */
    @ApiModelProperty(value="返回信息")
    private String message;

    /**
     * 响应对象
     */
    @ApiModelProperty(value="返回对象")
    private T data;

    public ApiResponseData() {
    }

    public ApiResponseData(Boolean success, Integer code, String message, T data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public ApiResponseData(Integer code, String message, T data) {

        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ApiResponseData(String message, T data) {
        this.message = message;
        this.data = data;
    }

    public static ApiResponseData success(String message, Object object){

        return new ApiResponseData(ApiTips.SUCCESS_CODE,message,object);
    }

    public static ApiResponseData error(String message, Object object){

        return new ApiResponseData(ApiTips.ERROR_CODE,message,object);
    }

    public static ApiResponseData auth(String message, Object object){

        return new ApiResponseData(ApiTips.Auth_Code,message,object);
    }

        public static ApiResponseData authCourse(String message, Object object){

            return new ApiResponseData(ApiTips.Auth_Course,message,object);
    }

//    public static SuccessResponseData success(Integer code, String message, Object object) {
//        return new SuccessResponseData(code, message, object);
//    }
//
//    public static ErrorResponseData error(String message) {
//        return new ErrorResponseData(message);
//    }
//
//    public static ErrorResponseData error(Integer code, String message) {
//        return new ErrorResponseData(code, message);
//    }
//
//    public static ErrorResponseData error(Integer code, String message, Object object) {
//        return new ErrorResponseData(code, message, object);
//    }
}
